<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>t_listen</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4>NAME</h4><blockquote>
t_listen - listen for a connection indication
</blockquote><h4>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;<a href="xti.h.html">xti.h</a>&gt;

int t_listen(
    int fd,
    struct t_call *call)
</code>
</pre>
</blockquote><h4>DESCRIPTION</h4><blockquote>
<pre>
<P><table  bordercolor=#000000 border=1 align=center><tr valign=top><th align=center><b>Parameters</b>
<th align=center><b>Before call</b>
<th align=center><b>After call</b>
<tr valign=top><td align=left>fd
<td align=center>x
<td align=center>/
<tr valign=top><td align=left>call-&gt
<td align=center>addr.maxlen
<td align=center>x
<tr valign=top><td align=left>call-&gt
<td align=center>addr.len
<td align=center>/
<tr valign=top><td align=left>call-&gt
<td align=center>addr.buf
<td align=center>?
<tr valign=top><td align=left>call-&gt
<td align=center>opt.maxlen
<td align=center>x
<tr valign=top><td align=left>call-&gt
<td align=center>opt.len
<td align=center>/
<tr valign=top><td align=left>call-&gt
<td align=center>opt.buf
<td align=center>?
<tr valign=top><td align=left>call-&gt
<td align=center>udata.maxlen
<td align=center>x
<tr valign=top><td align=left>call-&gt
<td align=center>udata.len
<td align=center>/
<tr valign=top><td align=left>call-&gt
<td align=center>udata.buf
<td align=center>?
<tr valign=top><td align=left>call-&gt
<td align=center>sequence
<td align=center>/
</table>
</pre>
<p>
This function listens for a
connection indication from a calling transport user.
The argument
<I>fd</I>
identifies the local transport endpoint where connection
indications arrive,
and on return,
<I>call</I>
contains information describing the connection indication.
The parameter
<I>call</I>
points to a
<B>t_call</B>
structure which contains the following members:
<pre>
<code>
struct netbuf addr;
struct netbuf opt;
struct netbuf udata;
int sequence;
</code>
</pre>
<p>
In
<I>call</I>,
<I>addr</I>
returns the protocol address of the calling transport user.
This address is in a format usable in future calls to
<i><a href="t_connect.html">t_connect()</a></i>.
Note, however that
<i><a href="t_connect.html">t_connect()</a></i>
may fail for other reasons, for example [TADDRBUSY].
<I>opt</I>
returns options
associated with the connection indication,
<I>udata</I>
returns any user data sent by the caller on the connection request, and
<I>sequence</I>
is a number that uniquely identifies the returned connection
indication.
The value of
<I>sequence</I>
enables the user to listen for multiple connection indications
before responding to any of them.
<p>
Since this function returns values for the
<I>addr</I>,
<I>opt</I>
and
<I>udata</I>
fields of
<I>call</I>,
the
<I>maxlen</I>
field of each must be set before issuing the
<i>t_listen()</i>
to indicate the maximum size of the buffer for each.
If the 
<I>maxlen</I>
field of 
<I>call-&gt;addr</I>,
<I>call-&gt;opt</I>
or 
<I>call-&gt;udata</I>
is set to zero, no information is returned for this parameter.
<p>
By default,
<i>t_listen()</i>
executes in synchronous mode and
waits for a connection indication to arrive before returning to the user.
However, if O_NONBLOCK
is set via
<i><a href="t_open.html">t_open()</a></i>
or
<i><a href="fcntl.html">fcntl()</a></i>,
<i>t_listen()</i>
executes asynchronously, reducing
to a poll for existing connection indications.
If none are available, it returns -1 and sets
<I>t_errno</I>
to [TNODATA].
</blockquote><h4>VALID STATES</h4><blockquote>
T_IDLE, T_INCON
</blockquote><h4>ERRORS</h4><blockquote>
On failure,
<I>t_errno</I>
is set to one of the following:
<dl compact>

<dt>[TBADF]<dd>The specified file descriptor does not refer to a transport endpoint.

<dt>[TBADQLEN]<dd>The argument
<I>qlen</I>
of the endpoint referenced by
<I>fd</I>
is zero.

<dt>[TBUFOVFLW]<dd>The number of bytes allocated for an incoming argument
<I>(maxlen)</I>
is greater than 0 but not
sufficient to store the value of that argument.
The provider's state, as seen by the user, changes to
T_INCON, and
the connection indication information to be returned in
<I>call</I>
is discarded.
The value of
<I>sequence</I>
returned can be used to do a
<i><a href="t_snddis.html">t_snddis()</a></i>.

<dt>[TLOOK]<dd>An asynchronous event has occurred on this transport endpoint and requires
immediate attention.

<dt>[TNODATA]<dd>O_NONBLOCK
was set, but no connection indications had been queued.

<dt>[TNOTSUPPORT]<dd>This function is not supported by the underlying transport
provider.

<dt>[TOUTSTATE]<dd>The communications endpoint referenced by 
<I>fd</I>
is not in one of the states in which a call to this function is valid.

<dt>[TPROTO]<dd>This error indicates that a communication problem has been detected between
XTI and the transport provider for which there is no other suitable XTI
error
<I>(t_errno)</I>.

<dt>[TQFULL]<dd>The maximum number of outstanding connection 
indications has been
reached for the endpoint referenced by
<I>fd</I>.

Note that a subsequent call to
<i>t_listen()</i>
may block until another incoming connection indication
is available. This can only occur if at least one
of the outstanding connection indications becomes
no longer outstanding, for example through a call to
<i><a href="t_accept.html">t_accept()</a></i>.

<dt>[TSYSERR]<dd>A system error has occurred during execution of this function.

</dl>
</blockquote><h4>CAVEATS</h4><blockquote>
Some transport providers do not differentiate between
a connection indication and the connection itself.
If this is the case, a successful return of
<i>t_listen()</i>
indicates an existing connection (see
<xref href=ipsi></xref>).
</blockquote><h4>RETURN VALUE</h4><blockquote>
Upon successful completion, a value of 0 is returned.  Otherwise,
a value of -1 is returned and
<I>t_errno</I>
is set to indicate an error.
</blockquote><h4>SEE ALSO</h4><blockquote>
<i><a href="fcntl.html">fcntl()</a></i>,
<i><a href="t_accept.html">t_accept()</a></i>,
<i><a href="t_alloc.html">t_alloc()</a></i>,
<i><a href="t_bind.html">t_bind()</a></i>,
<i><a href="t_connect.html">t_connect()</a></i>,
<i><a href="t_open.html">t_open()</a></i>,
<i><a href="t_optmgmt.html">t_optmgmt()</a></i>,
<i><a href="t_rcvconnect.html">t_rcvconnect()</a></i>.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>
